package com.flower.core_service.config;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.*;

/**
 * @ClassName ConfigBean
 * @Description TODO
 * @Author 吃麻椒的花酱
 * @Date 2022/4/6 12:00
 * @Version 1.0
 */
@Configuration
public class ConfigBean {

    /**
     * @author 吃麻椒的花酱
     * @date 2022/4/15 17:51
     * @Description 自定义线程池
     * @return java.util.concurrent.ThreadPoolExecutor
     */
    @Bean(name = "executeFlower")
    public ThreadPoolExecutor threadPoolExecutor() {
        RejectedExecutionHandler rejected = new ThreadPoolExecutor.DiscardPolicy();
       return new ThreadPoolExecutor(1,2, 5,
                                     TimeUnit.SECONDS, new ArrayBlockingQueue<>(10,true),
                                     Executors.defaultThreadFactory(), rejected);
    }
}
